import request from "@/utils/request";

/**
 * 系统管理 API
 */

/**
 * 获取系统列表
 * @param {Object} params - 查询参数
 * @param {string} params.applicationCode - 系统编码
 * @param {string} params.name - 系统名称
 * @param {string} params.status - 系统状态
 * @param {number} params.ownerId - 负责人ID
 * @param {number} params.pageNum - 页码
 * @param {number} params.pageSize - 页面大小
 * @returns {Promise}
 */
export const getApplicationList = (params) => {
  return request({
    url: "/api/system/ae/applications",
    method: "get",
    params,
  });
};

/**
 * 获取系统详情
 * @param {number} applicationId - 系统ID
 * @returns {Promise}
 */
export const getApplicationById = (applicationId) => {
  return request({
    url: `/api/system/ae/applications/${applicationId}`,
    method: "get",
  });
};

/**
 * 创建系统
 * @param {Object} data - 系统数据
 * @param {string} data.applicationCode - 系统编码
 * @param {string} data.name - 系统名称
 * @param {string} data.status - 系统状态
 * @param {number} data.sort - 排序值
 * @param {number} data.ownerId - 负责人ID
 * @param {string} data.remark - 备注
 * @returns {Promise}
 */
export const createApplication = (data) => {
  return request({
    url: "/api/system/ae/applications",
    method: "post",
    data,
  });
};

/**
 * 更新系统
 * @param {number} applicationId - 系统ID
 * @param {Object} data - 系统数据
 * @returns {Promise}
 */
export const updateApplication = (applicationId, data) => {
  return request({
    url: `/api/system/ae/applications/${applicationId}`,
    method: "put",
    data,
  });
};

/**
 * 删除系统
 * @param {number} applicationId - 系统ID
 * @returns {Promise}
 */
export const deleteApplication = (applicationId) => {
  return request({
    url: `/api/system/ae/applications/${applicationId}`,
    method: "delete",
  });
};

/**
 * 启用系统
 * @param {number} applicationId - 系统ID
 * @returns {Promise}
 */
export const enableApplication = (applicationId) => {
  return request({
    url: `/api/system/ae/applications/${applicationId}/enable`,
    method: "post",
  });
};

/**
 * 禁用系统
 * @param {number} applicationId - 系统ID
 * @returns {Promise}
 */
export const disableApplication = (applicationId) => {
  return request({
    url: `/api/system/ae/applications/${applicationId}/disable`,
    method: "post",
  });
};
